#!/usr/bin/env python3
"""
直接在服务器上测试换脸功能（绕过API）
"""
import asyncio
import sys
sys.path.insert(0, '/root/FaceFusion')

from pathlib import Path
import base64

async def test_direct():
    # 导入handler
    from api.faceswap_handler import faceswap_handler
    
    # 读取图片
    with open('/tmp/test_source.jpg', 'rb') as f:
        source_base64 = f"data:image/jpeg;base64,{base64.b64encode(f.read()).decode()}"
    
    with open('/tmp/test_target.jpg', 'rb') as f:
        target_base64 = f"data:image/jpeg;base64,{base64.b64encode(f.read()).decode()}"
    
    # 直接调用处理函数
    print("开始测试...")
    result = await faceswap_handler.process_faceswap(
        task_id="test-001",
        source_image_base64=source_base64,
        target_image_base64=target_base64,
        mode="beauty",
        output_quality=100
    )
    
    print(f"测试完成: {result}")

if __name__ == "__main__":
    asyncio.run(test_direct())

